package com.shujia.wyh.day11;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;

/*
    创建功能
        public boolean createNewFile()
        public boolean mkdir()
        public boolean mkdirs()
    删除功能
        public boolean delete()
    重命名功能
        public boolean renameTo(File dest)
    判断功能
        public boolean isDirectory()
        public boolean isFile()
        public boolean exists()
        public boolean canRead()
        public boolean canWrite()
        public boolean isHidden()
    基本获取功能
        public String getAbsolutePath()
        public String getPath()
        public String getName()
        public long length()
        public long lastModified()



 */
public class FileDemo2 {
    public static void main(String[] args) throws Exception {
//        File file = new File("java/src/com/shujia/wyh/day11/b.txt");
//
//        //public boolean createNewFile() 创建一个文件
//        System.out.println(file.createNewFile());


        //public boolean mkdir()
//        File file = new File("java/src/com/shujia/wyh/day11/aaa");
//        System.out.println(file.mkdir()); //只能创建单极目录

        //public boolean mkdirs()
//        File file = new File("java/src/com/shujia/wyh/day11/bbb/ccc/ddd");
//        System.out.println(file.mkdirs()); //可以创建多级目录

        //public boolean delete()
//        File file = new File("java/src/com/shujia/wyh/day11/bbb");
//        System.out.println(file.delete());  //如果要使用delete()删除目录的话，就必须保证该目录中没有其他文件或者文件夹

//        File file = new File("java/src/com/shujia/wyh/day11/b.txt");
//        System.out.println(file.delete());

        //public boolean renameTo(File dest)
//        File file1 = new File("java/src/com/shujia/wyh/day11/a.txt");
//        File file2 = new File("java/src/com/shujia/wyh/day11/陈涛.txt");
//        System.out.println(file1.renameTo(file2));


        //public boolean isDirectory()
        File file = new File("java/src/com/shujia/wyh/day11/陈涛.txt");
        System.out.println(file.isDirectory());

        //public boolean exists()
        System.out.println(file.exists());

        //public boolean canRead() 判断是否可读
        System.out.println(file.canRead());

        //public boolean canWrite()
        System.out.println(file.canWrite());

        //public boolean isHidden() 判断是否是一个隐藏文件
        System.out.println(file.isHidden());

        //public String getAbsolutePath() 获取绝对路径
        System.out.println(file.getAbsolutePath());

        //public String getPath()
        System.out.println(file.getPath());

        //public String getName()
        System.out.println(file.getName());

        //public long length()  返回的文件内容字节数
        System.out.println(file.length());

        //public long lastModified()  返回的是最后修改的时间戳
        System.out.println(file.lastModified());
        //1679381674655
        Date date = new Date(1679381674655L);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String time = sdf.format(date);
        System.out.println(time);


    }
}
